package com.taichuan.selfcheck.entity;

import android.hardware.usb.UsbDevice;
import android.os.Build;
import android.util.Log;

/**
 * 该类主要用于
 *
 * @author CamelLuo
 * @version 2021/11/4
 */
public class USBDeviceInfo {
    private static final String TAG = USBDeviceInfo.class.getSimpleName();

    /**
     * USB挂载文件路径
     */
    private String deviceFilePath;
    /**
     * USB厂家标识(VendorId)
     */
    private int vendorId;
    /**
     * USB产品标识(ProductId)
     */
    private int productId;
    /**
     * USB制造商名称
     */
    private String manufacturerName;
    /**
     * USB设备的产品名称
     */
    private String productName;
    /**
     * USB设备的版本
     */
    private String version;
    /**
     * USB设备的序列号
     */
    private String serialNumber;

    public USBDeviceInfo(UsbDevice usbDevice) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (usbDevice != null) {
                deviceFilePath = usbDevice.getDeviceName();
                //USB厂家标识(VendorId)
                vendorId = usbDevice.getVendorId();
                //USB产品标识(ProductId)
                productId = usbDevice.getProductId();
                //USB制造商名称
                manufacturerName = usbDevice.getManufacturerName();
                //USB设备的产品名称
                productName = usbDevice.getProductName();
                //USB设备的版本
                version = usbDevice.getVersion();
                //USB设备的序列号
                serialNumber = usbDevice.getSerialNumber();
            }
        }else {
            Log.e(TAG, "USBDeviceInfo: 设备的Android版本不支持，无法初始化 USBDeviceInfo 实体类");
        }
    }

    public USBDeviceInfo(String deviceFilePath, int vendorId, int productId, String manufacturerName, String productName, String version, String serialNumber) {
        this.deviceFilePath = deviceFilePath;
        this.vendorId = vendorId;
        this.productId = productId;
        this.manufacturerName = manufacturerName;
        this.productName = productName;
        this.version = version;
        this.serialNumber = serialNumber;
    }

    public String getDeviceFilePath() {
        return deviceFilePath;
    }

    public void setDeviceFilePath(String deviceFilePath) {
        this.deviceFilePath = deviceFilePath;
    }

    public int getVendorId() {
        return vendorId;
    }

    public void setVendorId(int vendorId) {
        this.vendorId = vendorId;
    }

    public int getProductId() {
        return productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    public String getManufacturerName() {
        return manufacturerName;
    }

    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    @Override
    public String toString() {
        return "USBDeviceInfo{" +
                "deviceFilePath USB挂载文件路径='" + deviceFilePath + '\'' +
                ", vendorId USB厂家标识=" + vendorId +
                ", productId USB产品标识=" + productId +
                ", manufacturerName USB制造商名称='" + manufacturerName + '\'' +
                ", productName= USB设备的产品名称'" + productName + '\'' +
                ", version USB设备的版本='" + version + '\'' +
                ", serialNumber USB设备的序列号='" + serialNumber + '\'' +
                '}';
    }
}
